<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ page import="beans.*"%>	
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
* {
	margin: 0;
	padding: 0;
}

#all {
	width: 400px;
	/* 	height: 200px; */
	margin: 100px auto;
	background-color: gray;
	border: 1px solid gray;
	border-radius: 5px;
	border-collapse: collapse;
}

#first {
	padding: 5px;
}

#first img {
	border: 0px;
	width: 16px;
	height: 16px;
	display:none;
}

#first a {
	color:white;

}
#second {
	background-color: #ffffff;
	margin: 0px 2px;
}

#third {
	/* 	background-color: #8cded8; */
	text-align: right;
	/* 	margin-bottom: 10px; */
	padding: 5px;
}

#third a {
	border-radius: 3px;
	border: 1px solid gray;
	text-decoration: none;
	color: white;
}
</style>
</head>
<body>
<%
	//方案1
	Object obj=application.getAttribute("counter");
	if(obj==null){
		Counter counter=new Counter();
		application.setAttribute("counter", counter);
	}//此方法不能防止刷新和tomcat重新启动

%>

<%
	//方案2 好，保存成数据库
	UserDAO userDAO2=new UserDAO();
	int current2;
	if(session.isNew()){
		//out.print("new");
		current2=userDAO2.addnum();//1表示要增加		
	}else{
		//out.print("old");
		current2=userDAO2.getnum();//2只是取数据
	}
	application.setAttribute("current2", current2);
	

%>

<%
	//方案3好，保存成文件
	UserDAO userDAO3=new UserDAO();
	int current3;
	if(session.isNew()){
		//out.print("new");
		current3=userDAO3.addnumfile(request);//1表示要增加		
	}else{
		//out.print("old");
		current3=userDAO3.getnumfile(request);//2只是取数据
	}
	application.setAttribute("current3", current3);
	

%>
	<div id="all">
		<div id="first">
			<div style="float: left">
				<img alt="" src="images/lock.png"> <span>欢迎进入登录窗口</span>
			</div>

			<div id="register" style="float: right">
				<a href="register.jsp"> <img alt=""
					src="images/rabbit2.png"> <span>注册</span>
				</a>
			</div>
			<div style="clear: both"></div>
		</div>

		<div id="second">
			<form name="form1" method="get" action="">
				<table>
					<tr>
						<td>
							<table>
								<tr>
									<td>用户</td>
									<td><input type="text" id="userno" name="userno"
										value="请输入用户号"></td>
								</tr>
								<tr>
									<td>密码</td>
									<td><input type="text" id="userpwd" name="userpwd"
										value="请输入密码"></td>

								</tr>
								<tr>
									<td colspan="2"><input type="radio" name="userident"
										value="管理员" checked="checked">管理员 <input type="radio"
										name="userident" value="普通用户">普通用户</td>

								</tr>
							</table>
						</td>
						<td><img alt="" src="images/pp.png"></td>
					</tr>
				</table>
			</form>

		</div>

		<div id="third">
			<!-- 以下#与javascript:void(0)都表示空链接，一般推荐使用javascript-->
 			<!--<a href="#" onclick="logincheck();return false;">  -->
			<a href="javascript:void(0)" onclick="logincheck();return false;"> 
				<img alt="" src="images/ok.png">
				登录
			</a>
		</div>

	</div>
	
	<script type="text/javascript">
	function  logincheck(){
		/*第3单元js代码
		var address=["mainadmin.jsp","main.jsp"];		
		var ident=form1.userident;//这里原写成userindent，运行不出来
		for(var i=0;i<ident.length;i++){
			if(ident[i].checked==true){
				window.location.href=address[i];
				//window.location.href=address[i]+"?userno="+form1.userno.value;
			}
		}
		//return false;目的是去除默读的跳转，也可以在html中写
		*/
		
		//第4单元代码
		
		//方法1
		form1.action="logincheck.jsp";
		form1.submit();
		
		//方法2
		/*var userno=form1.userno.value;
		var userpwd=form1.userpwd.value;
		var userident=form1.userident;
		for(var i=0;i<userident.length;i++){
			if(userident[i].checked==true){
				userident=userident[i].value;
			}
		}
		window.location.href="login-check.jsp?userno="+userno+"&userpwd="+userpwd+"&userident="+userident;
		*/
		
	}
	</script>

</body>
</html>
